package neuralNetworks;

import java.io.Serializable;

public class NeuronFactory<T extends Neuron> implements Serializable {
	private static final long serialVersionUID = -435678755398266422L;

	Class<T> neuronClass;

	public NeuronFactory(Class<T> neuronClass) {
		this.neuronClass = neuronClass;
	}

	public T create(Functions actFunc, double bias) throws InstantiationException, IllegalAccessException {
		T neuron = neuronClass.newInstance();
		neuron.actFunc = actFunc;
		neuron.bias = bias;
		return neuron;
	}

	public T copy(T neuron) throws InstantiationException, IllegalAccessException {
		T copy = neuronClass.newInstance();
		copy.actFunc = neuron.actFunc;
		copy.bias = neuron.bias;
		return copy;
	}

}
